<?php
require_once "weixin_info.php";//微信授权获取用户头像等信息
require_once "config.php";
require_once "jssdk.php";
$jssdk = new JSSDK();
$signPackage = $jssdk->GetSignPackage();
$id = $_GET['id'];
$u_id = !empty($id) ? $id : $_SESSION['Member_info'][0]['id'];
if(!empty($u_id)){
    $sql = $mysql->query("select * from dyspw_member where id=".$u_id);//视频
    $member_info = $sql->fetch_all(MYSQLI_ASSOC);
}else{
    $member_info = $_SESSION['Member_info'];
}
//
//    /*微信支付*/
//    require_once "WxPay.php";
//    $WxPay = new WxPay();
//    $trade_no = mt_rand(1000000000,9999999999);;
//    $Result = $WxPay->SubmitJsApiUnifiedOrder('吉事多', $trade_no, 0.01);
//    $SignParam = $WxPay->signJsApiPrepayParam($Result['prepay_id']);
//
//获取作品集
// echo $u_id;exit;
$sql = $mysql->query("select * from dyspw_weblink where u_id=".$u_id);
$rows = $sql->fetch_all(MYSQLI_ASSOC);
$link_sql = $mysql->query("select * from dyspw_like where uid=".$u_id." and state = 1");
$like = $link_sql->fetch_all(MYSQLI_ASSOC);
$user_sql = $mysql->query("select * from dyspw_userfavorite where uid=".$u_id." and isshow = 1");
$user = $user_sql->fetch_all(MYSQLI_ASSOC);
$foll_sql = $mysql->query("select * from dyspw_follow where fans_id=".$u_id);//关注
$foll = $foll_sql->fetch_all(MYSQLI_ASSOC);
$fans_sql = $mysql->query("select * from dyspw_follow where u_id=".$u_id);//粉丝
$fans = $fans_sql->fetch_all(MYSQLI_ASSOC);
$goods_sql = $mysql->query("select * from dyspw_goods where u_id=".$u_id ." ORDER BY time DESC limit 6");//ç²‰ä¸
$goods = $goods_sql->fetch_all(MYSQLI_ASSOC);
$user_arr = array();
foreach ($user as $key => $val) {
    $web_sql = $mysql->query("select * from dyspw_weblink where id=".$val['aid']);
    $array = $web_sql->fetch_all(MYSQLI_ASSOC);
    if(!empty($array)){
        $user_arr[] = $array[0];
    }
}
$like_arr = array();
foreach ($like as $key => $val) {
    $web_sql = $mysql->query("select * from dyspw_weblink where id=".$val['weblinkid']);
    $array = $web_sql->fetch_all(MYSQLI_ASSOC);
    $like_arr[] = $array[0];
}
$like_count = 0;
foreach ($rows as $key => $val) {
    $web_sql = $mysql->query("select * from dyspw_like where weblinkid=".$val['id']);
    $array = $web_sql->fetch_all(MYSQLI_ASSOC);
    $like_count =  $like_count + count($array);
}
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>个人中心</title>
    <link rel="stylesheet" href="css/core.css">
    <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
    <script src="js/jquery.cookie.js" type="text/javascript"></script>
    <script src="js/layer/layer.js" type="text/javascript"></script>
    <style media="screen">
            <?php if($member_info[0]['is_vip'] == 3){?>
                .grls-info-box{background: url(images/mem_shop.png) center center no-repeat}
            <?php }else{ ?>
                .grls-info-box{background:  url(images/mem_geren.png) center center no-repeat;}
            <?php } ?>
            .grls-menu-box ul li.cur div{background-image: url("./images/user_menu_bg.png");}
    </style>
    <style>
        .talkSpan{
    display: inline-block;
    background: #6594f5;
    float: right;
    color: #FFF;
    font-size: 12px;
    border-radius: 12px;
    display: block;
    line-height: 25px;
    height: 25px;
    width: 64px;
    text-align: center;
}
    </style>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cb5d49b07e0a753dc8ee27ba2c73495d";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body>
<section style="padding-bottom:50px;">
    <div class="main" style="width:90%;">

        <div class="grls-info-box cl" style="padding-bottom:0px;">
            <div class="" style="display: inline-block; width:100%;">
                <div class="grls-avatar-box">
                    <a href="shop_edit.php"><img src="<?php echo $member_info[0]['avatar'] ?>" /></a>
                </div>
                <div class="grls-desc-box" style="position: relative;">
                    <?php if(empty($id)){?><a href="address_setup.php"><img src="images/mem_setup.png" alt="" style="width: 20px;position: absolute;right: 0px;top: 7px;"></a><?php  } ?>
                    <a href="shop_edit.php"><h2 style="<?php if(!empty($id)){echo 'background:none';} ?>"><?php echo $member_info[0]['username'] ?></h2></a>
                    <p><?php echo $member_info[0]['intro'] ?></p>
                    <div class="btn-box cl">
                        <!-- <a href="#"><img src="images/header-search.png">æŸ¥æ‰¾</a> -->
                        <a href="#" style="float:left;"><?php if($member_info[0]['is_vip'] == 3 ){echo "商户";}elseif ($member_info[0]['is_vip'] == 2) {echo "个人";}elseif ($member_info[0]['is_vip'] == 4) {echo "业务员";}elseif ($member_info[0]['is_vip'] == 1) {echo "拍客";}else{echo "游客";}?></a>
                        <?php if(empty($id)){ ?>
                            <?php if($member_info[0]['is_vip'] == 3 ){ ?>
                                <a style="float:left; margin-left:10px;" href="javascript:void(0);" onclick="toScan();"><img src="images/sys.png">扫一扫</a>
                                <span class="talkSpan">聊天室</span>
                                <?php  }elseif ($member_info[0]['is_vip'] == 4 ) { ?>
                                    <a style="float:left; margin-left:10px;" href="personalCenter.php">业务员中心</a>
                                    <?php } ?>
                        <?php  } ?>
                    </div>
                </div>
            </div>
            <p style="    line-height: 40px;padding-left: 10px;">
                <span style="margin-right: 10px;font-size: 12px;color: white;"><em><?php echo $like_count; ?></em> 获赞</span>
                <a href="follow.php<?php if(!empty($id)){ echo '?id='.$id;} ?> ">
                    <span style="margin-right: 10px;font-size: 12px;color: white;"><em><?php echo count($foll); ?></em> 关注</span>
                    <span style="font-size: 12px;color: white;"><em><?php echo count($fans); ?></em> 粉丝</span>
                </a>
            </p>
		</div>

        <?php if(empty($id)){?>
            <div class="grls-menu-box">
                <ul class="cl">
<!--                    <li class="cur"><div style=""> <a href="https://5p8.fyh5p8.com/xiaochengxu/fenlei.php"><img src="images/icon_fl.png" /></a></div>分类</li>-->
<!--                    <li><div><img src="images/icon_qb.png" /></div>钱包</li>-->
<!--                    <li><div><img src="images/icon_kf.png" /></div>客服</li>-->
                    <li class="cur"> <div style=""> <a href="https://5p8.fyh5p8.com/xiaochengxu/fenlei.php"><img src="images/icon_fl.png" /></a></div>分类</li>
                    <li><a href="wallet.php"><div><img src="images/icon_qb.png" /></div>钱包</a></li>
                    <?php if($member_info[0]['is_vip'] == 3){?>
                        <li><a href="shop_edit.php"><div><img src="images/icon_sz.png" /></div>商铺设置</a></li>
                    <?php }else{ ?>
                        <li><a href="shop_edit.php"><div><img src="images/icon_sz.png" /></div>用户设置</a></li>
                    <?php } ?>
                    <!-- <li><div><a href="http://console.nuoyun.tv/Mobile/Index/index"><img src="images/icon_bf.png" /></a></div>直播</li> -->
                </ul>
            </div>
            <?php } ?>

		<div class="grls-banner-box" style="    margin-top: 10px;">
            <a href="recharge.php"><img src="images/grls_banner.png" /></a>
		</div>

        <?php if($member_info[0]['is_vip'] == 3 || $member_info[0]['is_vip'] == 2){?>
		<div class="grls-spjx-box">

			<h2 class="cl"><font>商品精选</font><p>Product selection</p>
                <?php if(empty($id)){ ?>
                <a href="goods_edit.php" style="    display: inline-block;float: right;font-size: 14px;border: 1px solid #C79400;line-height: 30px;padding: 0px 10px;border-radius: 6px;background: #C79400;color: #fff;margin-top: 5px;">添加商品</a>
                <?php } ?>
            </h2>

            <div class="spjx-box">
				<ul class="cl">
                    <?php if(!empty($goods)){foreach ($goods as $key => $val) { if($key < 4){?>
                        <li><a href="goods_info.php?id=<?php echo $val['id'];?>"><img src="<?php echo $val['img'] ?>" /><span style="text-align: left;float: left;">原价:<?php echo $val['money'] ?><br/ ><em style="font-size: 14px;color: red;">团购价:<?php echo $val['group_money'] ?></em></span><p class="title"><?php echo $val['title'] ?></p><p><?php echo $val['details']; ?></p></a></li>
                    <?php }} ?>
                    <?php if($member_info[0]['is_vip'] == 3 || $member_info[0]['is_vip'] == 2){?>
                        <?php if(empty($id)){?><li style="padding: 0px;"><a href="goods_edit.php" style="    display: block;width: 100px;"><img src="images/add_goods.png" alt=""></a></li><?php } ?>
                    <?php }} ?>
				</ul>
			</div>

		</div>
        <?php } ?>


        <style>
            .navigationBox{background: #3f79f3;border-radius: 5px;color: #fff;padding:15px 8px;height: auto;overflow: hidden}
            .navigationBox img{float: left;width: 20px;}
            .navigationBox p{float: left;margin-left: 5px;height: auto;overflow: hidden}
            .navigationBox a{float:right;height: auto;overflow: hidden;background: #fff;color: #000;border-radius: 5px;padding: 3px 10px;margin-top:3px}
        </style>
        <div id='container1' style="display:none"></div>
        <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=d021bae86db1d54dddc4071a5123749c&plugin=AMap.Geocoder"></script>
        <script type="text/javascript">
            var ipBool=false;
            var lng,lat;
            AMap.plugin('AMap.Geolocation', function() {
                var geolocation = new AMap.Geolocation({
                    enableHighAccuracy: true,
                    timeout: 10000,
                    buttonOffset: new AMap.Pixel(10, 20),
                    zoomToAccuracy: true,
                    buttonPosition: 'RB'
                });
                geolocation.getCurrentPosition();
                AMap.event.addListener(geolocation, 'complete', onComplete);
                AMap.event.addListener(geolocation, 'error', onError);
                function onComplete (result) {
                    lng=result.position.getLng();
                    lat=result.position.getLat();
                    <?php if($member_info[0]['shop_lng'] && $member_info[0]['shop_lat']){?>
                    ipBool=true;
                    var p1 =  new AMap.LngLat(lng, lat);
                    var p2 =  new AMap.LngLat(<?php echo $member_info[0]['shop_lng']?>, <?php echo  $member_info[0]['shop_lat']?>);
                    var distance = Math.round(p1.distance(p2));
                    $(".navigationBox p font").html(distance);
                    <?php }?>
                }

                function onError (data) {
                    // alert(JSON.stringify(data));
                }
            });

            function navigation() {
                if(window.navigator.userAgent == 'AndroidNative'){
                    dsBridge.call("mapSite", {lng: "<?php echo $member_info[0]['shop_lng']?>", lat: "<?php echo $member_info[0]['shop_lat']?>", name: "<?php echo $member_info[0]['shop_add']?>"});
                } else if (window.navigator.userAgent == 'IosNative') {
                    dsBridge.call("mapSite", {lng: "<?php echo $member_info[0]['shop_lng']?>", lat: "<?php echo $member_info[0]['shop_lat']?>", name: "<?php echo $member_info[0]['shop_add']?>"});
                } else {
                    if(ipBool){
                        window.location.href="http://uri.amap.com/navigation?from="+lng+","+lat+"&to=<?php echo $member_info[0]['shop_lng']?>,<?php echo  $member_info[0]['shop_lat']?>&mode=car&name='<?php echo $member_info[0]['shop_add']?>'&src=nyx_super";
                    }else {
                        <?php if($member_info[0]['shop_lng'] && $member_info[0]['shop_lat']){?>
                        alert('定位信息获取失败，请查看GPS是否开启');
                        <?php }else{?>
                        alert('商家位置信息未完善');
                        <?php }?>
                    }
                }
            }
        </script>

        <div class="navigationBox">
            <img src="./images/dingwei.png">
            <p><?php echo $member_info[0]['shop_add']?><br>
                距您<font>10000</font>米
            </p>
            <a onclick="navigation()">导航</a>
        </div>



        <div class="video-nav-box grls cl">
            <?php if($member_info[0]['is_vip'] == 3){ ?>
                <style media="screen">.video-nav-box.grls a{width: 25%!important;}</style>
                <a href="mem_goods.php<?php if(!empty($id)){ echo '?id='.$id;} ?>" >商品 <?php echo count($goods); ?></a>
            <?php    } ?>
			<a href="member.php<?php if(!empty($id)){ echo '?id='.$id;} ?>   " >作品 <?php echo count($rows); ?>  </a>
			<a href="mem_collection.php<?php if(!empty($id)){ echo '?id='.$id;} ?>" >收藏<?php echo count($user_arr); ?></a>
			<a href="mem_like.php<?php if(!empty($id)){ echo '?id='.$id;} ?>" class="cur">喜欢 <?php echo count($like); ?></a>
		</div>

		<div class="video-box grls" id="Collection">
			<ul class="cl">
                <?php foreach ($like_arr as $k=>$v){?>
                    <li>
                        <a href="content.php?id=<?php echo $v['id'];?>">
                            <div class="" style="position: relative;">
                                <img  src="<?php echo $v['linkurl']."?vframe/jpg/offset/1/w/368/h/640/rotate/auto";?>" class="">
                                <p style="    position: absolute;bottom: 0px;">
                                    <!-- <?php if(!empty($v['lng']) && !empty($v['lat'])){?>
                                        <img  src="./images/adress.png" alt="" style="width: 25px;">
                                        <span id="juli<?php //echo $v['id'];?>" class="julitxt" lng="<?php //echo  $v['lng'];?>" lat="<?php //echo  $v['lat'];?>" style="color: #fff;font-size: 12px;letter-spacing: 1px;"></span>
                                    <?php } ?>
                                </p> -->
                            </div>
                            <h2 style="font-size: 11px"><?php echo $v['webnote']?></h2>
                            <div class="video-desc"><div class="fl"><?php echo $v['webname']?></div><em><?php echo $v['hits']?></em></div>
                        </a>
                    </li>
                <?php }?>



			</ul>

		</div>
	</div>
    <!-- <div class="main" style="width:90%;">


        <ul class="menu-box cl">
            <li><a href="fenlei.php"><i>分类</i></a></li>

            <li><a href="#"><i>收藏</i></a></li>
            <li><a href="#" class="wxpay"><i>充值</i></a></li>
            <li><a href="recharge.php" ><i>充值</i></a></li>
            <li><a href="#"><i>客服</i></a></li>
            <li><a href="#"><i>设置</i></a></li>
        </ul>
    </div> -->

</section>
<?php if(empty($id)){?>
    <footer style="background-color:#FFF;">
        <ul class="cl">
            <li><a href="index.php">首页</a></li>
            <li><a href="fenlei.php">分类</a></li>
            <li><a href="baishe.php">拍</a></li>
            <li><a href="shopping.php">商城</a></li>
            <li><a href="member.php">我</a></li>
        </ul>
    </footer>
<?php } ?>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">

    $(function(){

        $(".grls-menu-box li").click(function(){
    		$(this).addClass("cur").siblings().removeClass("cur");
    	});

        // $(".wxpay").click(function(){
    	// 	WeixinJSBridge.invoke(
    	// 		'getBrandWCPayRequest',
    	// 		{
    	// 			"appId" : '<?php //echo $SignParam['appId']; ?>',
    	// 			"timeStamp" : '<?php //echo $SignParam['timeStamp']; ?>',
    	// 			"nonceStr" : '<?php //echo $SignParam['nonceStr']; ?>',
    	// 			"package" : '<?php //echo $SignParam['package']; ?>',
    	// 			"signType" : '<?php //echo $SignParam['signType']; ?>',
    	// 			"paySign" : '<?php //echo $SignParam['paySign']; ?>',
    	// 		},
        //
    	// 		function(ret){
    	// 			if(ret.err_msg == "get_brand_wcpay_request:cancel"){
    	// 				layer.open({content:"您已取消了此次支付",skin:'msg',time:3});
    	// 			}else if(ret.err_msg == "get_brand_wcpay_request:fail"){
    	// 				layer.open({content:"支付失败，请重新尝试",skin:'msg',time:3});
    	// 			}else if(ret.err_msg == "get_brand_wcpay_request:ok"){
    	// 				layer.open({content:"支付成功",skin:'msg',time:3});
    	// 				//location.href = '';//跳转支付成功页面
    	// 			}else{
    	// 				layer.open({content:"未知错误"+ret.err_msg,skin:'msg',time:3});
    	// 			}
    	// 		}
    	// 	);
    	// });



    });



</script>
<script type="text/javascript">



</script>
</body>
</html>
